//
//  MHSearchView.m
//  ManHua
//
//  Created by 江子安 on 15/10/29.
//  Copyright © 2015年 蓝欧科技. All rights reserved.
//

#import "MHSearchView.h"

@implementation MHSearchView

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        _iconView = [[UIImageView alloc]initWithFrame:CGRectMake(20, 80, 30, 30)];
        _iconView.image = [UIImage imageNamed:@"iconfont-icon2"];
        [self addSubview:_iconView];
        
        _titleLabel = [[UILabel alloc]initWithFrame:CGRectMake(55, 80, 100, 30)];
        _titleLabel.text = @"大家都在搜";
        _titleLabel.font = [UIFont systemFontOfSize:15];
        [self addSubview:_titleLabel];
        
        CGFloat anW = (Width - 40 - 15 - 40)/16;
        CGFloat anH = 30;
        CGFloat anX = 20;
        CGFloat anY = 120;
        CGFloat anS = 5;// 间隙
        _nameBtn1 = [UIButton buttonWithType:UIButtonTypeSystem];
        _nameBtn2 = [UIButton buttonWithType:UIButtonTypeSystem];
        _nameBtn3 = [UIButton buttonWithType:UIButtonTypeSystem];
        _nameBtn4 = [UIButton buttonWithType:UIButtonTypeSystem];
        _nameBtn5 = [UIButton buttonWithType:UIButtonTypeSystem];
        _nameBtn6 = [UIButton buttonWithType:UIButtonTypeSystem];
        _nameBtn7 = [UIButton buttonWithType:UIButtonTypeSystem];
        _nameBtn8 = [UIButton buttonWithType:UIButtonTypeSystem];
        
        _nameBtn1.frame = CGRectMake(anX, anY, 5 * anW + 10, anH);
        _nameBtn2.frame = CGRectMake(CGRectGetMaxX(_nameBtn1.frame) + anS, anY, anW * 4 + 10, anH);
        _nameBtn3.frame = CGRectMake(CGRectGetMaxX(_nameBtn2.frame) + anS, anY, anW * 3 + 10, anH);
        _nameBtn4.frame = CGRectMake(CGRectGetMaxX(_nameBtn3.frame) + anS, anY, anW * 4 + 10, anH);
        _nameBtn5.frame = CGRectMake(anX, anY + 10 + anH, anW * 2 + 10, anH);
        _nameBtn6.frame = CGRectMake(CGRectGetMaxX(_nameBtn5.frame) + anS, anY + 10 + anH, anW * 4 + 10, anH);
        _nameBtn7.frame =CGRectMake(CGRectGetMaxX(_nameBtn6.frame) + anS, anY + 10 + anH, anW * 5 + 10, anH);
        _nameBtn8.frame = CGRectMake(CGRectGetMaxX(_nameBtn7.frame) + anS, anY + 10 + anH, anW * 5 + 10, anH);
        
        [self addSubview:_nameBtn1];
        [self addSubview:_nameBtn2];
        [self addSubview:_nameBtn3];
        [self addSubview:_nameBtn4];
        [self addSubview:_nameBtn5];
        [self addSubview:_nameBtn6];
        [self addSubview:_nameBtn7];
        [self addSubview:_nameBtn8];
        
        
        NSArray *arr = @[@"美食的俘虏",@"斗罗大陆",@"花千骨",@"失禁少女",@"风夏",@"诡水疑云",@"干物妹小埋",@"变成那个她"];
        
        UIImage *image = [UIImage imageNamed:@"redBtn2@3x.jpg"];
        UIImage *btnImg =  [image resizableImageWithCapInsets:UIEdgeInsetsMake(image.size.height/2,image.size.width/2, image.size.height/2, image.size.width/2)];
        
        for (int i = 0; i < 8; i++) {
            [((UIButton *)self.subviews[2 + i]) setTitle:arr[i] forState:UIControlStateNormal];
            [((UIButton *)self.subviews[2 + i]) setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
            [((UIButton *)self.subviews[2 + i]) setBackgroundImage:btnImg forState:UIControlStateNormal];
            ((UIButton *)self.subviews[2 + i]).layer.cornerRadius = 12;
            ((UIButton *)self.subviews[2 + i]).layer.masksToBounds = YES;
            ((UIButton *)self.subviews[2 + i]).titleLabel.font = [UIFont systemFontOfSize:15];
        }
        
        
        
        
        
    }
    return self;
}


/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
